package com.sntk.organauthomanager.infrastructure.db.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * @ClassName: RoleEntity
 * @author: wgchao
 * @createTime: 2020/7/21 3:32 PM
 * @Description: TODO
 */
@Table(name = "sys_organ_role_info", uniqueConstraints = @UniqueConstraint(columnNames = {"role_code", "institution_number"}))
@org.hibernate.annotations.Table(appliesTo = "sys_organ_role_info", comment = "角色信息")
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RoleEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    //机构编号
    @Column(name = "institution_number", length = 100, columnDefinition="varchar(100) COMMENT '所属机构编号'", nullable = false)
    private String institutionNumber;

    //角色码
    @Column(name = "role_code", length = 20, columnDefinition="varchar(20) COMMENT '角色码'", nullable = false)
    private String roleCode;

    //角色名
    @Column(name = "role_name", length = 100, columnDefinition="varchar(100) COMMENT '角色名'", nullable = false)
    private String roleName;

    //备注
    @Column(name = "remark", length = 200, columnDefinition="varchar(200) COMMENT '备注'")
    private String remark;

    @Column(name = "disabled", columnDefinition="bit(1) COMMENT '禁用标识'", nullable = false)
    private Boolean disabled;

    @Column(name = "del", nullable = false)
    private Boolean del;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "creator", length = 50)
    private String creator;

    @Column(name = "last_update_time")
    private Date lastUpdateTime;

    @Column(name = "last_updator", length = 50)
    private String lastUpdator;


    //乐观锁 ObjectOptimisticLockingFailureException异常
    @Version
    private Long version;
}
